﻿using System.ComponentModel.DataAnnotations;

namespace ASPItalia.ModelVirtualCasting.Messaging
{
    public class EmailMessage
    {
        [Required(AllowEmptyStrings = false)]
        [RegularExpression(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")]
        public string From { get; set; }
        
        [Required(AllowEmptyStrings = false)]
        [RegularExpression(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")]
        public string To { get; set; }

        [Required(AllowEmptyStrings = true)]
        public string Subject { get; set; }

        [Required(AllowEmptyStrings = true)]
        public string Body { get; set; }

        public EmailMessage()
        {
            this.From = Configuration.EmailMessageSender;
            this.To = Configuration.EmailMessageSender;
            this.Subject = string.Empty;
            this.Body = string.Empty;
        }

        public override string ToString()
        {
            return this.Subject ?? string.Empty;
        }
    }
}
